package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemExample;
import com.dongdongshop.service.ItemService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class ItemServiceImpl implements ItemService {
    @Resource
    private TbItemMapper tbItemMapper;

    @Override
    public List<TbItem> selectByItem(Long goodsId) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andGoodsIdEqualTo(goodsId);//得属于一个spu
        criteria.andStatusEqualTo("1");//状态要正常的 == 1
        return tbItemMapper.selectByExample(example);
    }

    @Override
    public TbItem selectById(Long skuId) {
        return tbItemMapper.selectByPrimaryKey(skuId);
    }
}
